﻿using System;
using System.Collections.Generic;
using System.Linq;
using www.Core.Contract.DataContract;
using www.Models;

namespace www.Data.DAO
{
    public class LanguageDAO
    {
        #region Value
        private readonly RelaxDataContext _context = new RelaxDataContext();
        #endregion

        #region Ham NextId

        public string NextId()
        {

            return null;
        }

        #endregion

        #region Ham lay du Lieu

        public IQueryable<RelaxLanguageDataContract> GetLanguageDataContracts()
        {
            var query = from c in _context.LANGUAGE_REFs
                        join v in _context.LANGUAGE_VALUEs on c.id equals v.languagecode
                        select new RelaxLanguageDataContract
                        {
                            Id = Convert.ToInt32(c.id),
                            Name = v.name,
                            ShortName = v.short_name,
                            Image = c.image,
                            Active = Convert.ToInt32(c.active),
                            IsDefault = Convert.ToInt32(c.isdefault),
                            Type = Convert.ToInt32(v.type)
                        };
            return query.Any() ? query : null;

        }
        #endregion

        #region Ham Add


        #endregion

        #region Ham Update


        #endregion

        #region Ham Delete


        #endregion
    }
}